home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 41
/
Aminet 41 (2001)(Schatztruhe)[!][Feb 2001].iso
/
Aminet
/
gfx
/
edit
/
AmiCAD_2.07.lha
/
AmiCAD
/
ARexx
/
Recopier.AmiCAD
< prev
next >
Wrap
Text File
|
2000-11-10
|
5KB
|
180 lines
/* Clonage d'un composant, en "augmentant sa référence"
Version 1.00: 22 décembre 1998
Version 1.01: 25 Février 1999 (modif appel ASKNUM)
Version 1.02: 13 Avril 2000 (adaptation version 2.05)
Version 1.03: 1 Novembre 2000 (correction bugs, copie à gauche)
Version 1.04: 10 Novembre 2000 (localisation anglais/français)
$VER: 1.04 (© R.Florac, 10 Novembre 2000)
Améliorations à faire: traitement références multiples, composants sans référence
*/
options results /* indispensable pour récupérer le résultat des macros */
signal on error /* pour l'interception des erreurs */
signal on syntax
'LANGUAGE'
if result="français.language" then fr=1
else fr=0
'FIRSTSEL'
o=result
if o=0 then do
if fr=1 then 'MESSAGE("Sélectionnez le"+CHR(10)+"composant à recopier"+CHR(10)+"avant d''appeler ce script")'
else 'MESSAGE("Select the component"+CHR(10)+"to duplicate"+CHR(10)+"before calling this script")'
exit
end
type=0
do while type=0
'TYPE('o')'
select
when result=1 then do
type=1
leave
end
when result=4 then do
type=4
leave
end
when result=11 then do
type=11
leave
end
when result=12 then do
type=12
leave
end
otherwise nop
end
'NEXTSEL('o')'; o=result
if o=0 then do
if fr=1 then 'MESSAGE("Sélection incorrecte")'
else 'MESSAGE("Bad selection")'
exit
end
end
if type=1 then 'READTEXT(GETREF('o'))'
else 'READTEXT('o')'
ref=result
j=numero_reference(ref)
ref=reference(ref)
'WIDTH(0)'; l=(result%10)*10
'HEIGHT(0)'; h=(result%10)*10
'COL(0)'; x0=result
'LINE(0)'; y0=result
if fr=1 then 'SELECT("Sens de la copie"+CHR(10)+"Vers le bas"+CHR(10)+"Vers la droite"+CHR(10)+"Vers le haut"+CHR(10)+"Vers la gauche")'
else 'SELECT("Copying direction"+CHR(10)+"To bottom"+CHR(10)+"To right"+CHR(10)+"To top"+CHR(10)+"To left")'
sens=result
if sens < 1 then exit
if fr=1 then 'ASKNUM("Combien de fois"+CHR(10)+"voulez-vous effectuer"+CHR(10)+"l''opération?",2)'
else 'ASKNUM("How many times"+CHR(10)+"do-you want to do"+CHR(10)+"the operation?",2)'
n=result
if n<1 then exit
if fr=1 then 'SELECT("Espace entre les copies"+CHR(10)+"10 pixels"+CHR(10)+"20 pixels"+CHR(10)+"30 pixels"+CHR(10)+"Automatique"+CHR(10)+"Spécifié")'
else 'SELECT("Space between the copies"+CHR(10)+"10 pixels"+CHR(10)+"20 pixels"+CHR(10)+"30 pixels"+CHR(10)+"Automatique"+CHR(10)+"Spécifié")'
pas = result
select
when pas=1 then pas=0
when pas=2 then pas=10
when pas=3 then pas=20
when pas=4 then do
if sens=1 | sens=3 then pas=h
else pas=l
end
when pas=5 then do
if fr=1 then 'ASKNUM("Pas entre les copies",10)'
else 'ASKNUM("Step between the copies",10)'
pas=result
end
otherwise exit
end
'COPY(5):SAVEALL' /* sauvegarde des éléments à copier */
do i=1 to n
select
when sens=1 then do /* Copie vers le bas */
yy=y0+(10+pas+h)*i
yy=(yy%10)*10
'PASTE(5,'x0','yy')'
end
when sens=2 then do /* Copie vers la droite */
xx=x0+(10+pas+l)*i
xx=(xx%10)*10
'PASTE(5,'xx','y0')'
end
when sens=3 then do /* Copie vers le haut */
yy=y0-(10+pas+h)*i
yy=(yy%10)*10
'PASTE(5,'x0','yy')'
end
otherwise do /* Copie vers la gauche (v1.03) */
xx=x0-(10+pas+l)*i
xx=(xx%10)*10
'PASTE(5,'xx','y0')'
end
end
if ref ~= "" then do
j=j+1
k=indice(type)
if type=1 then 'SETREF('k',"'ref||j'"):UNMARK(-1)'
else 'SETTEXT('k',"'ref||j'"):UNMARK(-1)'
end
end
exit
indice: procedure
parse arg type
'FIRSTSEL'
o=result
do while o>0
'TYPE('o')'
select
when result=type then return o
otherwise nop
end
'NEXTSEL('o')'; o=result
end
return 0
reference: procedure
parse arg ref
i=length(ref)
do while i>1
c=substr(ref,i,1)
if datatype(c)=NUM then ref=left(ref,i-1)
else return ref
i=i-1
end
return ref
numero_reference: procedure
parse arg ref
i=length(ref)
r=0
rang=1
do while i>1
c=substr(ref,i,1)
if datatype(c)=NUM then do
r=r+c*rang
rang=rang*10
end
else return r
i=i-1
end
return r
/* Traitement des erreurs, interruption du programme */
syntax:
erreur=RC
if fr=1 then 'MESSAGE("Script Recopier.AmiCAD"+CHR(10)+"Erreur de syntaxe"+CHR(10)+"en ligne 'SIGL'"+CHR(10)+"'errortext(erreur)'")'
else 'MESSAGE("Recopier.AmiCAD script"+CHR(10)+"Syntax error"+CHR(10)+"in line 'SIGL'"+CHR(10)+"'errortext(erreur)'")'
exit
error:
if fr=1 then 'MESSAGE("Script Recopier.AmiCAD"+CHR(10)+"Erreur en ligne 'SIGL'")'
else 'MESSAGE("Recopier.AmiCAD script"+CHR(10)+"Error in line 'SIGL'")'
exit